<template>
  <div class="video">
    <div :id="'mse' + index" v-for="(item, index) in list" :key="index"></div>
  </div>
</template>

<script lang="ts">
import { onMounted, reactive, toRefs } from "vue";
import Player from "xgplayer/dist/simple_player";
import volume from "xgplayer/dist/controls/volume";
import playbackRate from "xgplayer/dist/controls/playbackRate";
import screenShot from "xgplayer/dist/controls/screenShot";
// import { deviceDetection } from "/@/utils/deviceDetection";

export default {
  setup() {
    const state = reactive({
      list: [
        {
          url: "http://www.hsingdu.com:2727/video/beautiful01.mp4",
          poster: "",
        },
        {
          url: "http://www.hsingdu.com:2727/video/beautiful02.mp4",
          poster: "",
        },
        {
          url: "http://www.hsingdu.com:2727/video/beautiful03.mp4",
          poster: "",
        },
        {
          url: "http://www.hsingdu.com:2727/video/beautiful04.mp4",
          poster: "",
        },
        {
          url: "http://www.hsingdu.com:2727/video/beautiful05.mp4",
          poster: "",
        },
      ],
    });

    onMounted(() => {
      state.list.forEach((item, index) => {
        new Player({
          id: "mse" + index,
          autoplay: false,
          videoInit: true,
          screenShot: true,
          url: item.url,
          // poster: item.poster,

          height: 600,
          width: 337.5,

          fluid: false,
          controlPlugins: [volume, playbackRate, screenShot],
          playbackRate: [0.5, 0.75, 1, 1.5, 2], //传入倍速可选数组
        });
      });
      // new Player({
      //   id: "mse",
      //   autoplay: false,
      //   screenShot: true,
      //   url: "http://www.hsingdu.com:2727/video/beautiful01.mp4",
      //   poster:
      //     "https://s2.pstatp.com/cdn/expire-1-M/byted-player-videos/1.0.0/poster.jpg",
      //   // fluid: deviceDetection(),
      //   controlPlugins: [volume, playbackRate, screenShot],
      //   playbackRate: [0.5, 0.75, 1, 1.5, 2], //传入倍速可选数组
      // });
    });
    return {
      ...toRefs(state),
    };
  },
};
</script>

<style lang="scss" scoped>
#mse {
  flex: auto;
}
.video {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  div {
    margin: 30px;
  }
  // justify-content: space-between;
}
</style>
